package complex.java.serialize;

import java.util.ArrayList;
import java.util.List;

public class Main {
	static ISerializable javaSerializer = new JavaSerializable();
	static ISerializable hessianSerializer = new HessianSerializable();
	static ISerializable jsonSerializer = new JsonSerializable();
	static ISerializable xstreamSerializer = new XStreamSerializable();

	public static void main(String[] args) throws Exception {
		Order order = getOrder();
		//序列化反序列化
		javaSerializer.serialize(order);
		hessianSerializer.serialize(order);
		jsonSerializer.serialize(order);
		xstreamSerializer.serialize(order);
	}

	static Order getOrder() {

		Order order = new Order();
		order.setOrderId(String.valueOf(1));
		order.setTotalNumber(10);

		List<Network> networks = new ArrayList<Network>();
		for(int i=0;i<100;i++){
			Network network = new Network();
			network.setNetworkId(String.valueOf(i));
			networks.add(network);
		}
		order.setNetworks(networks);
		return order;
	}
}
